package com.wgz.medicalmanagement.common.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * 生成BCrypt密码工具类
 */
public class GenerateBcryptPassword {
    
    public static void main(String[] args) {
        // 使用BCryptPasswordEncoder，默认强度为10
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        
        // 加密密码
        String rawPassword = "123456";
        String encodedPassword = encoder.encode(rawPassword);
        
        // 输出结果
        System.out.println("原始密码: " + rawPassword);
        System.out.println("加密密码: " + encodedPassword);
        System.out.println("\nSQL更新语句:");
        System.out.println("UPDATE sys_user SET password='" + encodedPassword + "' WHERE username='admin';");
        
        // 验证
        boolean matches = encoder.matches(rawPassword, encodedPassword);
        System.out.println("\n验证结果: " + matches);
    }
} 